﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Ucb.Workshop.Presenters;
using Ucb.Workshop.Business.Util;

namespace Ucb.Workshop.WinApp.View.GestionUsuario
{
    public partial class RegistroUsuarioView : UserControl, IUsuarioView
    {
        private RegistroUsuarioPresenter presenter;

        public RegistroUsuarioView()
        {
            InitializeComponent();
            presenter = new RegistroUsuarioPresenter(this);
            comboBoxEstado.SelectedIndex = 1;
        }

        private void btnRegistrarUsuario_Click(object sender, EventArgs e)
        {
            presenter.OnRegistroUsuario();
            LimpiarVista();
        }

        private void LimpiarVista()
        {
            txtEmail.Text = string.Empty;
            txtApellido.Text = string.Empty;
            txtEmail.Text = string.Empty;
            txtFono.Text = string.Empty;
            txtLogin.Text = string.Empty;
            txtNombre.Text = string.Empty;
            txtPwd.Text = string.Empty;
            comboBoxEstado.SelectedIndex = 1;
        }

       public bool validarUsuario()
        {
            if (UtilControl.ValidarTextBox(txtLogin) && UtilControl.ValidarTextBox(txtPwd) && UtilControl.ValidateText(txtNombre.Text) && UtilControl.ValidateText(txtApellido.Text) && UtilControl.ValidateAddress(txtDireccion.Text) && UtilControl.ValidateEmail(txtEmail.Text) && UtilControl.ValidateTelephone(txtFono.Text))
                return true;
            else
                return false;
        }

        #region IUsuarioView Members

        public string Login
        {
            get
            {
                return txtLogin.Text; 
            }
        }

        public string Password
        {
            get
            {
                return txtPwd.Text;
            }
        }

        public string Nombre
        {
            get
            {
                return txtNombre.Text;
            }
        }

        public string Apellido
        {
            get
            {
                return txtApellido.Text;
            }
        }

        public string Telefono
        {
            get
            {
                return txtApellido.Text;
            }
        }

        public string Direccion
        {
            get
            {
                return txtDireccion.Text;
            }
        }

        public string Email
        {
            get
            {
                return txtEmail.Text;
            }
        }

        public string Estado
        {
            get
            {
                return comboBoxEstado.Text;
            }
        }

        #endregion
    }
}
